package com.itheima.user.service.impl;

import com.itheima.order.clients.Orderclient;
import com.itheima.order.entity.Order;
import com.itheima.user.entity.User;
import com.itheima.user.entity.UserOrderDTO;
import com.itheima.user.mapper.UserMapper;
import com.itheima.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Autowired
    private Orderclient orderclient;

    @Override
    public UserOrderDTO findUserOrderByUserId(Long userId) {
        System.out.println("开始查询user数据");
        User user=userMapper.findUserOrderByUserId(userId);

        System.out.println(user);

        List<Order> orders = orderclient.findOrderByUsername(user.getUsername());

        UserOrderDTO userOrderDTO = new UserOrderDTO(user, orders);

        return userOrderDTO;
    }
}
